<template>
    <div class="EventBusBrother">
        <p>事件总线使用案例：兄弟组件传值，brother</p>
        <button @click="messageSister" class="btn">给妹妹发消息</button>
        <div v-if="fromSister" class="alert" v-html="fromSister"></div>
    </div>
</template>
/* 使用事件总线，EventBusBrother */
<script>
import { eventBus } from '../main.js'
export default {
    name: 'EventBusBrother',
    data() {
        return {
            theCardTitle: "Brother Card",
            fromSister: ""
        }
    },
    created() {
        eventBus.$on('sisterSaid', message => {
            this.fromSister = message
        })
    },
    mounted() {
        console.log('事件总线', eventBus)
    },
    methods: {
        messageSister() {
            // console.log('给妹妹的消息已经发出')
            eventBus.$emit("brotherSaid", "妈妈说，妹妹 该做作业了！(^_^)!!!");
        }
    },
    
}
</script>